package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 健康体检录入-第二页
 * 
 * @author houyuchun
 * 
 */
public class HealthExamFifthActivity extends AbstractControlActivity implements
		OnClickListener {

	private String createDate;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_health_exam_fifth);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addRadioGroupView(R.id.rad_tongzhuangxiong, "桶状胸");
		addRadioGroupView(R.id.rad_luoyin, "罗音");
		addRadioEditUnionView(new int[] { R.id.edt_luoyin_qita }, "罗音",
				new String[] { "罗音-其他" }, R.id.rad_luoyin, "其他");
		addRadioGroupView(R.id.rad_huxiyin, "呼吸音");
		addEditTextView(R.id.edt_xinlvci, "心率");
		addRadioGroupView(R.id.rad_xinlv, "心律");
		addRadioGroupView(R.id.rad_zayin, "杂音");
		addRadioGroupView(R.id.rad_yatong, "压痛");
		addRadioGroupView(R.id.rad_baokuai, "包块");
		addRadioGroupView(R.id.rad_ganda, "肝大");
		addRadioGroupView(R.id.rad_pida, "脾大");
		addRadioGroupView(R.id.rad_yidongxingzy, "移动性浊音");
		addRadioGroupView(R.id.rad_xiazhishuizhong, "下肢水肿");
		addRadioGroupView(R.id.rad_zubeidongmai, "足背动脉搏动");

		// Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		controlManager.toControl();

		this.setButtonListener(this, R.id.btn_next, R.id.btn_previous);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_previous:
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			// 前一页按钮
			intent.setClass(this, HealthExamFourthActivity.class);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_next:
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			intent.setClass(this, HealthExamSixthActivity.class);
			startActivity(intent);
			this.finish();
			break;
		default:
			break;
		}
	}

}
